package com.icinfo.cloud.provider.punish.ucase.punishdecide.controller;

import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.dto.DecideFormDto;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.dto.PublicityInfoQueryDto;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.dto.PunishDecideFormDto;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.dto.PunishDecideFormVo;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.service.IPunishDecideService;
import com.icinfo.cloud.provider.punish.ucase.punishdecide.vo.PublicityInfoVo;
import com.icinfo.framework.common.web.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 描述：处罚决定前端控制器
 *
 * @author xiangyuyu
 * @date 2022/2/17 09:02
 */
@RestController
@RefreshScope
@RequestMapping("/punish/ucase/punish/decide")
@Slf4j
public class PunishDecideController {
    @Resource
    private IPunishDecideService iPunishDecideService;

    /**
     * 【V2.0.0】描述：获取处罚决定表单数据
     * @author liyafeng
     * @date 2022/2/16
     * @param decideFormDto
     * @return {@link Result< PunishDecideFormVo>}
     */
    @PostMapping(value = "/getDecideFormBaseinfo",produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<PunishDecideFormVo> getDecideFormBaseinfo(@RequestBody @Validated(BaseGroup.Query.class) DecideFormDto decideFormDto){
        PunishDecideFormVo punishDecideFormVo=iPunishDecideService.getDecideFormBaseinfo(decideFormDto);
        return Result.success("获取成功",punishDecideFormVo);
    }

    /**
     * 【V1.0.0】描述：保存处罚决定表单数据
     * @author liyafeng
     * @date 2022/2/17
     * @param punishDecideFormDto
     * @return {@link Result< String>}
     */
    @PostMapping(value = "/saveDecideFormBaseinfo",produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<String> saveDecideFormBaseinfo(@RequestBody PunishDecideFormDto punishDecideFormDto){
        int num=iPunishDecideService.saveDecideFormBaseinfo(punishDecideFormDto);
        if(num<1){
            return Result.error("保存失败");
        }
        return Result.success("保存成功");
    }


    /**
     * 【V1.3.2】描述： 查询公示信息
     *
     * @author: zhengqiang
     * @date: 2022/7/21
     * @param: publicityInfoQueryDto
     * @return {@link Result< PublicityInfoVo>}
     **/
    @PostMapping("/getPublicityInfo")
    public Result<PublicityInfoVo> getPublicityInfo(@Validated @RequestBody PublicityInfoQueryDto publicityInfoQueryDto) {
        PublicityInfoVo publicityInfoVo = iPunishDecideService.getPublicityInfo(publicityInfoQueryDto);
        return Result.success(publicityInfoVo);
    }

}
